package com.ld.control.business.robot.controller;


import com.ld.control.business.robot.service.HuiLingRobotPointVariableService;
import com.ld.control.business.robot.vo.req.HuiLingRobotPointVariableReqVo;
import com.ld.control.business.robot.vo.resp.HuiLingRobotPointVariableRespVo;
import com.ld.control.common.PrimaryKeyReqVo;
import com.ld.control.common.ResultResponse;
import com.ld.control.common.vo.GeneratePageListVo;
import com.ld.control.sysenum.ResultResponseEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 机械臂点位信息 前端控制器
 * </p>
 *
 * @author wangfeng
 * @since 2025-09-12
 */
@Tag(name = "慧灵机械臂点位变量配置相关接口")
@RestController
public class HuiLingRobotPointVariableController {


    @Autowired
    private HuiLingRobotPointVariableService huiLingRobotPointVariableService;

    @GetMapping("/api/centralControl/huiLingRobotPointVariable/getPageList")
    @Operation(summary = "查询慧灵机械臂点位变量列表")
    public ResultResponse<GeneratePageListVo<HuiLingRobotPointVariableRespVo>> getPageList(
            @Parameter(description = "点位变量名称") @RequestParam(required = false) String name,
            @Parameter(description = "当前页")@RequestParam(required = false, defaultValue = "1") Integer current,
            @Parameter(description = "页大小")@RequestParam(required = false, defaultValue = "10") Integer size
    ) {
        GeneratePageListVo<HuiLingRobotPointVariableRespVo> huiLingRobotPointRespPageList = huiLingRobotPointVariableService.getPageList(name,current, size);
        return ResultResponse.success(huiLingRobotPointRespPageList);
    }

    @GetMapping("/api/centralControl/huiLingRobotPointVariable/getById")
    @Operation(summary = "查询详情")
    public ResultResponse<HuiLingRobotPointVariableRespVo> getById(
            @RequestParam Long id
    ) {
        return ResultResponse.success(huiLingRobotPointVariableService.getById(id));
    }

    @PostMapping("/api/centralControl/huiLingRobotPointVariable/add")
    @Operation(summary = "添加")
    public ResultResponse<ResultResponseEnum> add(
            @RequestBody HuiLingRobotPointVariableReqVo reqVo
    ) {
        huiLingRobotPointVariableService.add(reqVo);
        return ResultResponse.success();
    }

    @PostMapping("/api/centralControl/huiLingRobotPointVariable/update")
    @Operation(summary = "修改")
    public ResultResponse<ResultResponseEnum> update(
            @RequestBody HuiLingRobotPointVariableReqVo reqVo
    ) {
        huiLingRobotPointVariableService.update(reqVo);
        return ResultResponse.success();
    }

    @PostMapping("/api/centralControl/huiLingRobotPointVariable/deleteById")
    @Operation(summary = "根据id删除")
    public ResultResponse<ResultResponseEnum> deleteById(
            @RequestBody PrimaryKeyReqVo reqVo
    ) {
        huiLingRobotPointVariableService.deleteById(reqVo.getId());
        return ResultResponse.success();
    }

}

